//
//  const.h
//  haierapp
//
//  Created by Zhou Bing on 14-8-8.
//  Copyright (c) 2014年 haier. All rights reserved.
//

#ifndef haierapp_const_h
#define haierapp_const_h

#define combine(x, y)   [(x) stringByAppendingString:(y)]

#pragma mark -Service URL
//#define forTest      //测试服务器

#ifdef forTest
#define kBaseUrlADDR @"http://storetest.haier.com"
#else
#define kBaseUrlADDR @"http://store.haier.com"
#endif

#define kBaseUrl combine(kBaseUrlADDR, @"/app")


// 当前IOS版本
#ifndef __CUR_IOS_VERSION
#define __CUR_IOS_VERSION ([[[UIDevice currentDevice] systemVersion] floatValue] * 10000)
#endif
// 屏幕高度
#define kScreenHeight [UIScreen mainScreen].bounds.size.height
#define kScreenWidth  [UIScreen mainScreen].bounds.size.width
#define kAppWindow (UIWindow *)[[UIApplication sharedApplication].windows objectAtIndex:0]
#define kAppDelegate ((HRAppDelegate *)[UIApplication sharedApplication].delegate)

#endif

#pragma mark - For Compatibility (兼容)
// 对齐方式
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_6_0
#define TextAlignmentLeft   NSTextAlignmentLeft
#define TextAlignmentCenter NSTextAlignmentCenter
#define TextAlignmentRight  NSTextAlignmentRight
#else
#define TextAlignmentLeft   UITextAlignmentLeft
#define TextAlignmentCenter UITextAlignmentCenter
#define TextAlignmentRight  UITextAlignmentRight
#endif
// 文本属性
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_7_0
#define TextAttributeTextColor  NSForegroundColorAttributeName
#define TextAttributeFont       NSFontAttributeName
#else
#define TextAttributeTextColor  UITextAttributeTextColor
#define TextAttributeFont       UITextAttributeFont
#endif
// 获取文本高度
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_7_0
#define textSizeWithFont(text, font) [text length] > 0 ? [text \
sizeWithAttributes:@{NSFontAttributeName:font}] : CGSizeZero;
#else
#define textSizeWithFont(text, font) [text length] > 0 ? [text sizeWithFont:font] : CGSizeZero;
#endif
// 多行文本获取高度
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_7_0
#define multilineTextSize(text, font, maxSize) [text length] > 0 ? [text \
boundingRectWithSize:maxSize options:(NSStringDrawingUsesLineFragmentOrigin) \
attributes:@{NSFontAttributeName:font} context:nil].size : CGSizeZero;
#else
#define multilineTextSize(text, font, maxSize) [text length] > 0 ? [text \
sizeWithFont:font constrainedToSize:maxSize] : CGSizeZero;
#endif

#define kLoading @"正在加载"
